<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="requestInterFace.Handle.userHandle"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="requestInterFace.UserInfoInterFace.*"%>
<%@ page import="org.util.getNewData"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
		
		
String User_ID = request.getParameter("User_ID");
String Called_Time =request.getParameter("Called_Time");//开始访问时间
String userType=(String)session.getAttribute("User_Type");
String userID=(String)session.getAttribute("User_ID");
root root=new root();
if(userType==null||userID==null||!userType.equals("2")){
root.setStatus("false");
root.setMsg("权限不够");
PrintWriter pw = response.getWriter();
pw.println(root.getXmlString());
pw.flush();
return ;
}
 
		userinfo1_1 user=new userinfo1_1();
		
		if(User_ID==null||User_ID.equals("")){
			 root.setStatus("false");
			root.setMsg("请输入用户ID");
			PrintWriter pw = response.getWriter();
			pw.println(root.getXmlString());
			pw.flush();
			return ;
		}
		user.addequwhile(user.Mapfield("User_ID"), "=", User_ID);
		user.addequwhile(user.Mapfield("UP_ID"), "=", userID);
		user.setUpdateField("Called_Time", getNewData.GetNowDateAndTime("yyyy-MM-dd"));
		if(user.updata()>0){
			root.setStatus("true");
			taskinfo1_1 task=new taskinfo1_1();
		 task.setInsertField("Task_Title","(今日任务)拜访客户");
		 task.setInsertField("Task_Content", "在 "+getNewData.GetNowDateAndTime("yyyy-MM-dd")+" 拜访客户 "+User_ID);
		 task.setInsertField("Task_Type","拜访");
		task.setInsertField("Task_AddTime",getNewData.GetNowDateAndTime1());
		task.setInsertField("User_ID",userID);
		
		int row=task.insert();
		root.setRecords(""+row);//设置当前查询到的记录数
		if(row>0){
			root.setMsg("添加拜访任务成功");
		}else{
			root.setMsg("添加拜访任务失败,请手工添加");
		}
		}else{
			root.setStatus("false");
			root.setMsg("添加拜访任务失败");
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>

